﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/AdminSite.Master" Inherits="System.Web.Mvc.ViewPage<HuynhQuangWebsite.Models.Admin>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
<!-- Validation form -->
<%using (Html.BeginForm("Detail", "ManageAdmin", new { id = Model.AdminID }, FormMethod.Post, new { enctype = "multipart/form-data", @class = "form", id = "validate" }))
    { %>
    <%=ViewData["Msg"]%>
    <fieldset>
        <div class="widget">
          
            <div class="formRow">
                <label>Mật khẩu cũ:<span class="req">*</span></label>
                <div class="formRight"><%:Html.PasswordFor(model => model.OldPassword, new { @class = "validate[required]", id = "oldPassID",  onblur = "return CheckName()" })%>
                <div id="dvOldPass" style="visibility:collapse"> <span class="req"> Mật khẩu cũ không chính xác.</span></div>
                </div>
                 
                <div class="clear"></div>
            </div>
            <div class="formRow">
                <label>Mật khẩu mới:<span class="req">*</span></label>
                <div class="formRight"><%:Html.PasswordFor(model => model.Password, new { @class = "validate[required]", @readonly = "true", id = "reg" })%></div>
                <div class="clear"></div>
            </div>
            <div class="formRow">
                <label>Nhập lại:<span class="req">*</span></label>
                <div class="formRight"><%:Html.PasswordFor(model => model.ConfirmPassword, new { @class = "validate[required,equals[reg]]", @readonly = "true", id = "pwd" })%></div>
                <div class="clear"></div>
            </div>
        </div>
        <div class="widget">
             <div class="formSubmit"><input type="submit" value="cập nhật" class="blueB" /></div>
             <div><%:Html.HiddenFor(model => model.AdminID)%></div>
           <%} %>
            <div class="clear"></div>
           
        </div>
             
    </fieldset>
     <script type="text/javascript">

         function CheckName() {
             var id = $("#AdminID").val();
             var pwd = $("#oldPassID").val();
             $.post("/ManageAdmin/CheckPassword/", { id: id, pwd: pwd },
	                    function (data) {
	                        if (data === "True") {
	                            document.getElementById("reg").readOnly = false;
	                            document.getElementById("pwd").readOnly = false;
	                            $('#dvOldPass').css("visibility", "collapse");
	                            return true;
	                        }
	                        else {
	                            $('#dvOldPass').css("visibility", "visible");
	                            return false;
	                        }
	                    });
         }
        
         
       

     </script>

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="TitleAreaPlaceHolder" runat="server">
</asp:Content>
